From eae9c15a7cd76d886337b8034d9802ac9d9d7c2d Mon Sep 17 00:00:00 2001
From: Kit La Touche <kit@transneptune.net>
Date: Wed, 11 Feb 2026 14:56:58 -0500
Subject: Clean up service worker logic

There's an asymmetry between client/sw message passing, and push event
messages. I found that out experimentally. I was also mistakenly
assigning to the wrong attribute of the unread-status object.
Tentatively good now, but I need real new-message-events from the server
to be sure.
---
 ui/routes/(app)/c/[conversation]/+page.svelte | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'ui/routes/(app)/c/[conversation]/+page.svelte')

diff --git a/ui/routes/(app)/c/[conversation]/+page.svelte b/ui/routes/(app)/c/[conversation]/+page.svelte
index 24baa47..5a832ee 100644
--- a/ui/routes/(app)/c/[conversation]/+page.svelte
+++ b/ui/routes/(app)/c/[conversation]/+page.svelte
@@ -56,6 +56,14 @@
     if (!!at) {
       session.local.updateLastReadAt(conversationId, at);
     }
+
+    navigator.serviceWorker.ready.then((registration) => {
+      registration.active.postMessage({
+        type: 'CONVERSATION_READ',
+        conversationId,
+        at,
+      });
+    });
   }
 
   $effect(() => {
-- 
cgit v1.2.3

